package com.example.demo.saobeitest;


import com.alibaba.fastjson.JSONObject;
import com.example.demo.client.OpenParameters;
import com.example.demo.client.SpringClient;
import com.example.demo.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * 版权所有：重庆富民银行股份有限公司
 *
 * @Description: 9.1    短信验证码发送接口
 * @version: v1.0
 */
@RestController
@RequestMapping("/sendSms")
public class SendMessageController {
    @Autowired
    private SpringClient springClient;

    @GetMapping("/captchaImage")
    public void testSendmsgcode() throws Exception {
        String uuidStr = StringUtils.trimIndex(UUID.randomUUID().toString());

        JSONObject requestParam = new JSONObject();
//        Y 商户编号
        requestParam.put("merchant_no", "'8808001003058620");
//        Y 调用方用户ID  商户侧用户唯一ID
        requestParam.put("cust_merchant_no", "2334560127");
//        Y 交易流水号
        requestParam.put("trade_no_jd", uuidStr);
////        C 富民二类电子户卡号
//        requestParam.put("base_acct_no", "条件必填");
//        Y 用户手机号
        requestParam.put("cust_mobile", "18907142062");
//        Y 验证码类型   0-开户、1-充值、2-提现、3-购买、4-赎回、5-电子账户一类户变更、6-二类户预留手机号变更
        requestParam.put("operate_type", "0");
//        Y 日志流水号
        requestParam.put("client_serial_no", uuidStr );
////        C 交易订单号   当operate_type为1、2、3、4时上送
//        requestParam.put("biz_channel_orderid", "");
////        C 交易金额    当operate_type为1、2、3、4时上送
//        requestParam.put("trade_amount", "");
////        C 产品编码    根据产品编码判断发送产品类型短信。
//        requestParam.put("product_id", "");

        OpenParameters.Builder builder = new OpenParameters.Builder();
        builder.apiName("com.fbank.open-api.finance.account")
                .apiCode("send-smi")
                .moduleCode("openapi-function")
                .param(requestParam.toJSONString());

        String response = springClient.send(builder.build());


        System.out.println("result is :" + response + " \n uuidStr " + (uuidStr));
    }

}
